package cc.bookcloud.tool.ocr.util;
/*==========================================================================
 * Copyright (C) Wit2Cloud Co.,Ltd
 * All Rights Reserved.
 * Created By 开源学社
 ==========================================================================*/

/**
 * @Desc: 字符串操作类
 * @author John Goo
 * @version 1.0
 * @ClassName: StringUtil
 * @history v1.0
 */
public class StringUtil {

    public static boolean isEmpty(String str){
        if(str ==null || "".equals(str)){
            return true;
        }
        return false;
    }

    public static String extractParent(String servletPath){
        boolean last = servletPath.endsWith("/");
        String temp = "";
        // 去掉最后的/为末尾
        if(last){
            int pos = servletPath.lastIndexOf("/");
            temp = servletPath.substring(0,pos);
        }else {
            temp = servletPath;
        }
        if(temp.endsWith("/fs")){
            temp = "/fs";
        }else {
            String[] arr = temp.split("/");
            String lastChild = arr[arr.length-1];
            temp = temp.replace(lastChild,"");
            temp = temp.replace("//","/");
        }

        return temp;
    }

    public static void main(String[] args) {

        String fs = "/fs";
        System.out.println(fs.endsWith("fs"));



    }
}
